﻿using System;
public partial struct EntitasVec3
{
    public float x;
    public float y;
    public float z;

    public static EntitasVec3 Zero { get { return new EntitasVec3(0, 0, 0); } }
    public static EntitasVec3 Up { get { return new EntitasVec3(0, 1, 0); } }
    public static EntitasVec3 Down { get { return new EntitasVec3(0, -1, 0); } }
    public static EntitasVec3 Left { get { return new EntitasVec3(-1, 0, 0); } }
    public static EntitasVec3 Right { get { return new EntitasVec3(1, 0, 0); } }
    public static EntitasVec3 Forward { get { return new EntitasVec3(0, 0, 1); } }
    public static EntitasVec3 Back { get { return new EntitasVec3(0, 0, -1); } }


    public EntitasVec3(float x, float y)
    {
        this.x = x;
        this.y = y;
        z = 0;
    }

    public EntitasVec3(float x, float y, float z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }



    public void Setvector(float Newx, float NewY, float NewZ)
    {
        x = Newx;
        y = NewY;
        z = NewZ;
    }

    public override bool Equals(object obj)
    {
        if (obj is EntitasVec3)
        {
            EntitasVec3 vec = (EntitasVec3)obj;
            if (vec == this)
                return true;
            else return false;
        }
        else return false;
    }

    public override string ToString()
    {
        return ("X=" + x + " Y=" + y + " Z=" + z);
    }
    public override int GetHashCode()
    {
        var hashCode = 373119288;
        hashCode = hashCode * -1521134295 + base.GetHashCode();
        hashCode = hashCode * -1521134295 + x.GetHashCode();
        hashCode = hashCode * -1521134295 + y.GetHashCode();
        hashCode = hashCode * -1521134295 + z.GetHashCode();
        return hashCode;
    }

    public static bool operator ==(EntitasVec3 a, EntitasVec3 b)
    {
        if (a.x == b.x && a.y == b.y && a.z == b.z)
            return true;
        else return false;
    }

    public static bool operator !=(EntitasVec3 a, EntitasVec3 b)
    {
        if (a.x != b.x || a.y != b.y || a.z != b.z)
            return true;
        else return false;
    }

    public static EntitasVec3 operator +(EntitasVec3 a, EntitasVec3 b)
    {
        var sum = new EntitasVec3
        {
            x = a.x + b.x,
            y = a.y + b.y,
            z = a.z + b.z
        };
        return sum;
    }

    public static EntitasVec3 operator -(EntitasVec3 a, EntitasVec3 b)
    {
        var difference = new EntitasVec3
        {
            x = a.x - b.x,
            y = a.y - b.y,
            z = a.z - b.z
        };
        return difference;
    }

    public static EntitasVec3 operator *(EntitasVec3 a, float value)
    {
        a.x *= value;
        a.y *= value;
        a.z *= value;
        return a;
    }

    public static EntitasVec3 operator /(EntitasVec3 a, float value)
    {
        a.x /= value;
        a.y /= value;
        a.z /= value;
        return a;
    }

    public static float ClampVlaue(float value, float min, float max)
    {
        if (value <= min)
            return min;
        else if (value >= max)
            return max;
        else return value;
    }

    public static float ClampMinValue(float value, float min)
    {
        if (value <= min)
            return min;
        else return value ;
    }

    public static float ClampMaxValue(float value, float max)
    {
        if (value >= max)
            return max;
        else return value;
    }
   
}